package com.webchat.chat.core.shiro;

import com.webchat.chat.core.enums.UserAccountType;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.io.Serializable;

/**
 * 自定义Authentication对象，使得Subject除了携带用户的登录名外还可以携带更多信息.
 * Created by Owner on 2018/6/27.
 */
public class ShiroUser implements Serializable {

    public String userId;
    public String tenantCode;
    public String userName;
    public UserAccountType userAccountType;
    public String pwdConnect;
    public String ip;
    public String groupId;
    public String groupName;

    public ShiroUser(String userId, String tenantCode, String userName, UserAccountType userAccountType, String pwdConnect, String ip, String groupId, String groupName) {
        this.userId = userId;
        this.tenantCode = tenantCode;
        this.userName = userName;
        this.userAccountType = userAccountType;
        this.pwdConnect = pwdConnect;
        this.ip = ip;
        this.groupId=groupId;
        this.groupName = groupName;
    }

    /**
     * 本函数输出将作为默认的<shiro:principal/>输出.
     */
    @Override
    public String toString() {
        return userName;
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this, "userName");
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj, "userName");
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public UserAccountType getUserAccountType() {
        return userAccountType;
    }

    public void setUserAccountType(UserAccountType userAccountType) {
        this.userAccountType = userAccountType;
    }

    public String getPwdConnect() {
        return pwdConnect;
    }

    public void setPwdConnect(String pwdConnect) {
        this.pwdConnect = pwdConnect;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
}

